import request from '@/utils/request'

export const login = (data) => {
    return request({
        url: 'auth/login',
        method: 'post',
        data
    })
}

export const outLogin = (data) => {
    return request({
        url: 'auth/logout',
        method: 'post',
        data
    })
}

export const getInfo = (data) => {
    return request({
        url: 'auth/getInfo',
        method: 'post',
        data
    })
}

export const getUserMenus = (data) => {
    return request({
        url: 'auth/getMenus',
        method: 'get',
        data
    })
}

export const getAllMenus = (data) => {
    return request({
        url: 'auth/getAllMenus',
        method: 'get',
        data
    })
}

export const saveMenus = (data) => {
    return request({
        url: 'auth/saveMenus',
        method: 'post',
        data
    })
}

export const deleteMenus = (data) => {
    return request({
        url: 'auth/deleteMenus',
        method: 'post',
        data
    })
}

// 角色管理相关接口
export const getRoles = (data) => {
    return request({
        url: 'auth/getRoles',
        method: 'get',
        params: data
    })
}

export const saveRole = (data) => {
    return request({
        url: 'auth/saveRole',
        method: 'post',
        data
    })
}

export const deleteRole = (data) => {
    return request({
        url: 'auth/deleteRole',
        method: 'post',
        data
    })
}

export const getRoleMenus = (data) => {
    return request({
        url: 'auth/getRoleMenus',
        method: 'get',
        params: data
    })
}

export const saveRolePermission = (data) => {
    return request({
        url: 'auth/saveRolePermission',
        method: 'post',
        data
    })
}

// 用户管理相关接口
export const getUsers = (data) => {
    return request({
        url: 'auth/getUsers',
        method: 'get',
        params: data
    })
}

export const saveUser = (data) => {
    return request({
        url: 'auth/saveUser',
        method: 'post',
        data
    })
}

export const deleteUser = (data) => {
    return request({
        url: 'auth/deleteUser',
        method: 'post',
        data
    })
}

// 个人信息管理相关接口
export const updateProfile = (data) => {
    return request({
        url: 'auth/updateProfile',
        method: 'post',
        data
    })
}

export const changePassword = (data) => {
    return request({
        url: 'auth/changePassword',
        method: 'post',
        data
    })
}

export const uploadAvatar = (data) => {
    return request({
        url: 'auth/uploadAvatar',
        method: 'post',
        data,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}